package com.probiz.estore.common.model.sales;

import com.probiz.estore.common.model.product.ProductType;
import com.probiz.estore.common.model.sales.base.GiftTbl;

/**
 * Model class for Gift. Add not database mapped fileds in this class.
 */
public class Gift extends GiftTbl {
	public static final Short	GIFTKIND_GIFT			= 1;	// 性质,决定是否可运输等1=实体、2=服务、3=下载、4=点卡
	public final static Short	STATUS_NOTACTIVE		= 0;	// 不发布
	public final static Short	STATUS_ACTIVE			= 1;	// 发布
	public final static Short	STATUS_LOGICAL_DELETED	= -1;	// 逻辑删除

	/**
	 * 实体
	 */
	public static final Short	KIND_ENTITY = new Short("1");
	
	/**
	 * 服务
	 */
	public static final Short	KIND_SERVICE = new Short("2");
	 
	/**
	 * 软件（下载）
	 */
	public static final Short	KIND_SOFTWARE = new Short("3");
	

	/**
	 * 卡类产品
	 */
	public static final Short	KIND_CARD = new Short("4");
	
	private String				membershipNames;				// 会员名称
  	/**
	 * Default Empty Constructor for class Gift
	 */
	public Gift () {
		super();
	}
	/**
	 * Default Key Fields Constructor for class Gift
	 */
	public Gift (
		 Integer in_giftId
		) {
		super (
		  in_giftId
		);
	}
	
	public String getMembershipNames() {
		return membershipNames;
	}

	public void setMembershipNames(String membershipNames) {
		this.membershipNames = membershipNames;
	}
	
	/**
	 * 是否一个实体商品
	 * @return
	 */
	public boolean getIsPhysicalGift(){
		if(getKind().equals(Gift.KIND_ENTITY)){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 是否一个虚拟商品
	 * @return
	 */
	public boolean getIsDigitalGift(){
		if(!getKind().equals(Gift.KIND_ENTITY)){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 获取未分配的礼品库存数（即可用库存数＝现库存 － 冻结库存数）
	 * @return
	 */
	public Integer getAvailableQuantity() {
    	if(null!= this.quantityOnHand){
    		//有限库存
    		return this.quantityOnHand - allocatedQuantity;
    	}else{
    		//无限库存
    		return null;
    	} 
    }
}
